package com.leetcode.problems011;


/**
 * @Description https://leetcode-cn.com/problems/string-to-integer-atoi/
 * @Date 2021/11/20 14:34
 * @Author ghery
 * @Version V1.0
 */
public class Solution {
    public int maxArea(int[] height) {
        if(height == null || height.length < 2){
            return 0;
        }
        int l = 0;
        int r = height.length - 1;
        int maxArea = 0;
        while(l < r){
           int max =  (r - l) * Math.min(height[r],height[l]);
            maxArea = Math.max(max,maxArea);
            if (height[r] > height[l]) {
                l++;
            } else {
                r--;
            }
        }
        return maxArea;
    }

    public static void main(String[] args) {
        int[] arr = {1 ,8,6,2,5,4,8,3,7 };
        System.out.println(new Solution().maxArea(arr));
    }
}
